package com.yqw.enhance;

import static java.util.Arrays.asList;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.TreeSet;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import com.yqw.enhance.Int.IntLambda;

public class LambdaTest {
	public static void main(String[] args) {
		List<String> list = asList("1", "2", "3", "4", "5");
		List<String> collect = list.stream().sorted().collect(Collectors.toList());
		System.out.println(list.stream().map((x) -> "NO." + x).collect(Collectors.toList()));
		List<Track> lists = asList(new Track("王五", 20), new Track("王五", 20));
		list.stream().collect(Collectors.toCollection(TreeSet::new));

		Track t = new Track("王五", 20);
		Supplier<Track> track = Track::new;
		
		
		Predicate<Track> isT = Track::plic;
		Function<Track, Boolean> fisT = Track::plic;
		Map<Boolean, List<Track>> collect1 = lists.stream().collect(Collectors.partitioningBy(isT));

		
		
		Supplier<String> cf = t::getName;
		System.out.println(cf.get());

		
		
		Function<Track, String> ftrack = Track::getName;
		Function<Track, String> f = (k) -> k.getName();
		Map<String, List<Track>> collect2 = lists.stream().collect(Collectors.groupingBy(f));

		
		
		Consumer<Track> action = Track::print;
		action.accept(t);

		
		
		String collect3 = lists.stream().map(Track::getName).collect(Collectors.joining(",", "[", "]"));
		System.out.println(collect3);
		
		IntLambda li = () -> System.out.println("wangc");
		li.pub();
		Optional<Object> empty = Optional.empty();
		Optional<Object> ofNullable = Optional.ofNullable(null);
		if (empty.isPresent()) {
			empty.orElse("");
		}
	}
}
